package com.qingcloud.adminbackend.controller;

import com.qingcloud.adminbackend.base.AjaxResult;
import com.qingcloud.adminbackend.constant.WamingConstant;
import com.qingcloud.adminbackend.entity.equipment.*;
import com.qingcloud.adminbackend.entity.equipment.*;
import com.qingcloud.adminbackend.service.ISysEquipmentService;
import com.qingcloud.adminbackend.utils.CookieUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 设备池管理
 *
 * @author liyuhong
 */
@RestController
@RequestMapping("/sys-equipmentpool")
public class EquipmentPoolController {

    @Resource
    private ISysEquipmentService sysEquipmentService;

    @ApiOperation(value = "设备池的设备列表Api", notes = "设备池的设备列表Api", response = EquipmentPoolListDTO.class)
    @PostMapping("/equipmentPoolList")
    public AjaxResult equipmentPoolList(@RequestBody EquipmentPoolListBO equipmentPoolListBO) {
        return new AjaxResult(WamingConstant.SUCCESS, "", sysEquipmentService.equipmentPoolList(equipmentPoolListBO));
    }

    @ApiOperation(value = "设备池的设备[订单内设备移入移出]", notes = "设备池的设备[订单内设备移入移出]", response = EquipmentListDTO.class)
    @PostMapping("/equipmentPool")
    public AjaxResult equipmentPool(@RequestBody EquipmentListBO equipmentListBO) {
        return new AjaxResult(WamingConstant.SUCCESS, "", sysEquipmentService.equipmentPool(equipmentListBO));
    }

    @ApiOperation(value = "订单内设备[订单内设备移入移出]", notes = "订单内设备[订单内设备移入移出]", response = EquipmentListDTO.class)
    @PostMapping("/orderEquipment")
    public AjaxResult orderEquipment(@RequestBody EquipmentListBO equipmentListBO) {
        return new AjaxResult(WamingConstant.SUCCESS, "", sysEquipmentService.orderEquipment(equipmentListBO));
    }

    @ApiOperation(value = "订单内设备移入移出", notes = "订单内设备移入移出")
    @PostMapping("/orderEquipmentMoveToYichu")
    public AjaxResult orderEquipmentMoveToYichu(@RequestBody EquipmentDTO equipmentDTO, HttpServletRequest request) {
        String userId = CookieUtil.getUserId(request);
        return sysEquipmentService.orderEquipmentMoveToYichu(equipmentDTO, userId);
    }
}
